#!/bin/bash

# Everything has to succeed
set -o errexit

tin() {
  _tmp/deps/tin.tin "$@"
}

readonly pypath=.:$CDI_DEPS/docopt-master

Build() {
  # Build the tnet tool.  Set PYTHONPATH so it can import.
  PYTHONPATH=$pypath tin build-python bin.annex_ --out=$CDI_OUT/annex.tin

  poly build doc/
}

Test() {
  # TODO: there is failure
  #./run.sh all-tests
  exit 0
}

Deploy() {
  scp -v $CDI_OUT/annex.tin $CDI_DEPLOY_DEST/annex/latest/

  # Deploy the doc app.
  poly stage \
    --remote-root=/keg/deploy \
    --http-nodes=http://localhost:8050 \
    doc/
}

"$@"
